<?php

namespace App\Http\Requests\System;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class Role extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => [
                'required',
                Rule::unique('roles')
                ->ignore(request()->id)
                ->whereNull('deleted_at')
            ],
            // 'type' => 'required',
            // 'attr' => 'required',
            // 'default' => 'required',
            // 'description' => 'required',
        ];
    }
    public function messages(){
        return [
            'name.required' => '请输入角色名称',
            'name.unique' => '角色名称重复',
            'type.required' => '请输入角色类型',
            'attr.required' => '请输入角色属性',
            'default.required' => '请输入角色系统预置',
            'description.required' => '请输入角色说明',
        ];
    }

}
